var _contextPath;

$(document).ready(function() {
	doSearch();
	top.UppTabs.operator = top.getCurrentTagTitle();// 设置用户tab的标题值
});


/**
 */
function doSearch() {
	$("#data_list").datagrid(
			{
				onLoadError : function(data) {
					uppAjaxError(data);
				},
				queryParams : {
				},
				columns : [ [ {
					field : 'exportReportTime',
					title : '日期',
					width : 100,
					formatter : function(value, row, index) {
						var saleDate = (new Date(Number(value))).dateConvert();
						return saleDate.substr(0,10);
					}
				}, {
					field : 'exportReportTotalAmount',
					title : '未结算金额',
					width : 100,
					align : 'center'
				}, {
					field : 'exportReportName',
					title : '文件名称',
					width : 100,
					align : 'center'
				}, {
					field : 'settlementExportReportId',
					title : '操作',
					width : 100,
					align : 'center',
					formatter : function(value, row, index) {
						var exportLink = "导出";
						var detailLink = "未结算明细查看";
						var exportUrl = '<a id="" href="#" class="easyui-linkbutton" onclick=gotoExport('+value+');>'+exportLink+'</a>';
						var detailUrl = '<a id="" href="#" class="easyui-linkbutton" onclick=gotoDetail('+value+');>'+detailLink+'</a>';
						return exportUrl +"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+ detailUrl;
					}
				} ] ],
				autoRowHeight : true,
				fitColumns : true,
				pagination : true,
				rownumbers : true,
				singleSelect : true
			});
	
}


function gotoExport(reportid){
	$.ajax({
		type : 'POST',
		url :  contextPath + 'iccard/financialmanage/exportReport',
		data : {
			'settlementExportReportId' : reportid
		},
		dataType : 'json',
		success : function(root) {
			if (root.opResult == '0') {
				window.open(contextPath + "iccard/financialmanage/download?settlementExportReportId="+reportid);
				location.reload();
			} else {
				top.uppShow(root.msgDesc);
			}
		},
		error : function(data) {
			uppAjaxError(data);
		}
	});
}
function exportAll(){
	$.ajax({
		type : 'POST',
		url :  contextPath + 'iccard/financialmanage/exportReportAll',
		data : {
		},
		dataType : 'json',
		success : function(root) {
			if (root.opResult == '0') {
				window.open(contextPath + "iccard/financialmanage/download");
				location.reload();
			} else {
				top.uppShow(root.msgDesc);
			}
		},
		error : function(data) {
			uppAjaxError(data);
		}
	});
}
function gotoDetail(reportid){
	window.location.href = contextPath + "iccard/financialmanage/notSettleMerchantDetailList.jsp?settlementExportReportId="+reportid;
}
